package com.lazycat.backend.controller.cart;

import com.lazycat.backend.service.cart.AddToCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class AddToCarController {
    @Autowired
    private AddToCartService addToCartService;

    @PostMapping("cart/insert/")
    public Map<String, Object> insert(@RequestBody Map<String, String> map) {
        Integer userId = Integer.parseInt(map.get("userId"));
        Integer goodId = Integer.parseInt(map.get("goodId"));
        return addToCartService.add(goodId, userId);
    }

}
